MyDocument.getInitialProps   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
1
import React from 'react'
2
import Document, { Html, Head, Main, NextScript } from 'next/document'
3
/*
4
 * Some notes:
5
 * 1) _document.js will load on server side -> all this meta tag will be fetched by Scraper of Facebook, Linkedin, ...
6
 * 2) og:image need to be change name in order for FB to reload the new preview image
7
 * 3) sharing on staging env wont work, because og:url is set to main page
8
 */
9
class MyDocument extends Document {
10
  static async getInitialProps(ctx) {
11
    const initialProps = await Document.getInitialProps(ctx)
12
    return { ...initialProps }
13
  }
14
15
  render() {
16
    return (
17
      <Html lang="en">
18
        <Head>
19
          <meta
20
            name="viewport"
21
            content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"
22
          />
23
          <meta property="og:title" content="PhatHo Portfolio and Website" />
24
          <meta property="og:type" content="website" />
25
          <meta
26
            property="og:description"
27
            content="Fullstack Software Engineer. 5+ years of algorithm background since high school. 5+ years of experience specializing in frontend/backend development"
28
          />
29
          <meta
30
            property="og:image"
31
            content="https://phatho-dev.com/images/cover-img.png"
32
          />
33
          <meta
34
            property="og:image:secure_url"
35
            content="https://phatho-dev.com/images/cover-img.png"
36
          />
37
          <meta property="og:url" content="https://phatho-dev.com" />
38
          <meta
39
            property="og:site_name"
40
            content="PhatHo Portfolio and Website"
41
          />
42
          <meta
43
            property="og:image:alt"
44
            content="PhatHo Portfolio and Website"
45
          />
46
          <meta
47
            name="google-site-verification"
48
            content="ofwBFRuFL3aycSJjDcrhc8hWEPKuJ7LkNCLUrsB0Sj4"
49
          />
50
          <meta name="robots" content="index,follow" />
51
          <meta name="googlebot" content="index,follow" />
52
          <meta name="theme-color" content="#ffffff" />
53
          <meta
54
            name="description"
55
            content="Fullstack Software Engineer. 5+ years of algorithm background since high school. 5+ years of experience specializing in frontend/backend development"
56
          />
57
          <meta
58
            name="keywords"
59
            content="portfolio, phatho, dekal, software engineer, freelancer, cv, work"
60
          />
61
          <meta name="author" content="Phat Ho" />
62
          <link rel="icon" href="/favicon.ico" />
63
          <link rel="apple-touch-icon" href="/icons/Icon-64.png" />
64
          <link
65
            rel="preload"
66
            href="fonts/ip/font/ip.woff"
67
            as="font"
68
            crossOrigin=""
69
          />
70
          <link
71
            href="/icons/Icon-32.png"
72
            rel="icon"
73
            type="image/png"
74
            sizes="32x32"
75
          />
76
          <link
77
            href="/icons/Icon-64.png"
78
            rel="icon"
79
            type="image/png"
80
            sizes="64x64"
81
          />
82
83
          <link rel="canonical" href="https://phatho-dev.com" />
84
          <link rel="manifest" href="/manifest.json" />
85
86
          <script
87
            async
88
            defer
89
            src="https://www.googletagmanager.com/gtag/js?id=UA-172952138-1"
90
          />
91
92
          <script
93
            dangerouslySetInnerHTML={{
94
              __html: `
95
              window.dataLayer = window.dataLayer || [];
96
              function gtag(){dataLayer.push(arguments);}
97
              gtag('js', new Date());
98
            
99
              gtag('config', 'UA-172952138-1');
100
              `
101
            }}
102
          />
103
        </Head>
104
        <body>
105
          <Main />
106
          <NextScript />
107
        </body>
108
      </Html>
109
    )
110
  }
111
}
112
113
export default MyDocument
114